$(function () {
   obj.init();
});
var obj = new function () {
    'use strict';
    return {
        form:null,
        id:null,
        init:function () {
            this.form = new xhForm($('#xh_form')).parse();
            this.id = xhTool.getQuery('id');
            if (formData) {
                this.form.fill(formData);
            }
            this.listener();
        },
        listener:function () {
            var $this = this;
            //double处理
            $('.doubleInput').on('change',function () {
                $this.funObj().toFormatDouble($(this).val(), $(this));
            });
            //点击保存
            $('#bt_modal_confirm', parent.document).click(function () {
                $this.funObj().submitFormAction();
            })
        },
        funObj:function () {
            var $this = this;
            return {
                toFormatDouble:function (number,dom) {
                    var f = parseFloat(number);
                    if (isNaN(f)) {
                        dom.val('0.00');
                    }
                    var f = Math.round(number*100)/100;
                    var s = f.toString();
                    var rs = s.indexOf('.');
                    if (rs < 0) {
                        rs = s.length;
                        s += '.';
                    }
                    while (s.length <= rs + 2) {
                        s += '0';
                    }
                    dom.val(s);
                    第
                    0
                    共0页

                },
                submitFormAction:function () {
                    var $params = {};
                    if ($this.id) {
                       $params.iProdId = $this.id;
                    }
                    $this.form.submit('ims/produce/saveProduce', $params, function (res) {
                        window.top.xhTop.showSuccess(res.msg);
                        window.top.xhTop.getActiveFrame().obj.prodDataGrade.reload();
                        window.top.xhTop.closeModal();
                    })
                }
            }
        }
    }
};
